package shajie.shajun.mmhf.View.Fragment;

import android.content.Context;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.widget.Toast;

import com.flyco.tablayout.SlidingTabLayout;
import com.flyco.tablayout.listener.OnTabSelectListener;

import shajie.shajun.mmhf.Base.BaseFragment;
import shajie.shajun.mmhf.R;
import shajie.shajun.mmhf.databinding.FragmentContent2Binding;

/**
 * Created by admin on 2018/1/8.
 */

public class Content2_Fragment extends BaseFragment<FragmentContent2Binding> {
    private FragmentContent2Binding mbinding;
    private SlidingTabLayout tabLayout_1;
    public SectionsPagerAdapter sectionsPagerAdapter;
    @Override
    public int setlayoutid() {
        return R.layout.fragment_content2;
    }

    @Override
    public void init(FragmentContent2Binding binding) {
        mbinding=binding;
        sectionsPagerAdapter=new SectionsPagerAdapter(getContext(),getActivity().getSupportFragmentManager());
        binding.pager.setAdapter(sectionsPagerAdapter);
        tabLayout_1=binding.slitablayout;
        tabLayout_1.setViewPager(binding.pager);
        tabLayout_1.setOnTabSelectListener(new OnTabSelectListener() {
            @Override
            public void onTabSelect(int position) {
                Toast.makeText(getContext(), "onTabSelect&position--->" + position, Toast.LENGTH_SHORT).show();
            }
            @Override//重复点击同一个选项执行
            public void onTabReselect(int position) {
//                mFragments.add(SimpleCardFragment.getInstance("后端"));
//                mAdapter.notifyDataSetChanged();
//                tabLayout_7.addNewTab("后端");
            }
        });
    }
    public static  class SectionsPagerAdapter extends FragmentPagerAdapter {
        private Context context2;
        public OutGoods_Fragment mOutGoods_fragment;
        public SectionsPagerAdapter(Context context,FragmentManager fm) {
            super(fm);
            this.context2=context;
            mOutGoods_fragment=new OutGoods_Fragment();
        }
        @Override
        public Fragment getItem(int position) {
            switch (position){
                case 0:
                    return mOutGoods_fragment;//子类页面
            }
            return null;
        }
        @Override
        public int getCount() {
            // Show 3 total pages.
            return 1;
        }

        @Override
        public CharSequence getPageTitle(int position) {
            switch (position) {
                case 0:
                    return "发货数据";
            }
            return null;
        }
    }
}
